package com.yiren.dbaa.module.practice_set.carmodel.presenter;

import android.app.Activity;

import com.yiren.dbaa.currency.api.CommonCallBack;
import com.yiren.dbaa.module.practice_set.carmodel.bean.CarBrandBean;
import com.yiren.dbaa.module.practice_set.carmodel.contract.AddCarContract;
import com.yiren.dbaa.module.practice_set.carmodel.model.AddCarModel;
import com.yiren.dbaa.view.dialog.LoadDialog;
import com.yiren.dbaa.view.toast.MessageBox;

import java.util.List;

/**
 * Describe
 *
 * @author WRX
 * @date 2022/12/5
 */
public class AddCarPresenter implements AddCarContract.Presenter {

    private Activity activity;
    private AddCarContract.Model addCarModel;

    public AddCarPresenter(Activity activity) {
        this.activity = activity;
        addCarModel = new AddCarModel(activity);
    }

    @Override
    public void getAllCarBrand(AddCarContract.View view) {
        LoadDialog.show(activity, "正在获取车辆品牌...");
        addCarModel.loadAllCarBrand(new CommonCallBack() {
            @Override
            public void success(Object result) {
                LoadDialog.dismiss(activity);
                List<CarBrandBean> carBrandBeans = (List<CarBrandBean>) result;
                if (null == carBrandBeans ||carBrandBeans.size() == 0) {
                    MessageBox.show(activity, "没有获取到车辆品牌信息！");
                } else {
                    view.showCarBrand(carBrandBeans);
                }
            }
        });
    }
}
